home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / sleep.tab.p < prev    next >
Text File  |  2003-01-03  |  16KB  |  442 lines

  1. {
  2.   X = 601;
  3.   Y = 65;
  4.   state = 0;
  5.   rest_x = 601;
  6.   expand_x = 400;  
  7.   Hidden = 1;
  8.   ChildID = {
  9.  
  10.     GuiAnimation("plate") {
  11.       AnimationID = "gui/dash/tab/plate/plate.pcx";
  12.       X = 39;
  13.       Width = 240;
  14.       Height = 180;
  15.     },
  16.  
  17.     
  18.     GuiAnimation("tab") {
  19.       Y = 118;
  20.       AnimationID = "gui/dash/tab/sleep/sleep_off.pcx";
  21.       ScriptID = script {
  22.         @activate {
  23.           resid Parent;
  24.           resid Player;
  25.           resid Game;
  26.           Game = ResByName("Game");
  27.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  28.           Parent = GuiParent(SELF);
  29.  
  30.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  31.             ResPropSetResID(Player,"truck_tab_expanded",RES_INVALID);
  32.           } else {
  33.             ResPropSetResID(Player,"truck_tab_expanded",Parent);
  34.             GuiToFront(Parent);
  35.           }
  36.         }
  37.         @animate {
  38.           resid Parent;
  39.           int state;
  40.           resid Player;
  41.           resid Game;
  42.           Game = ResByName("Game");
  43.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  44.           Parent = GuiParent(SELF);
  45.  
  46.           /* if we can sleep here, highlight me */
  47.           if (ResPropGetInt(Player,"nav_can_sleep") == 1) {
  48.             if (ResPropGetInt(Player,"player_fatigue")  < 10800 /* 3 hours */) {
  49.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/sleep/sleep_off.pcx"));
  50.             } else {
  51.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/sleep/sleep_on.pcx")); 
  52.             }
  53.           } else {
  54.             ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/sleep/sleep_off.pcx"));
  55.           }
  56.  
  57.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  58.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"expand_x"));
  59.             ResPropSetInt(GuiSiblingByName("plate"),"Hidden",FALSE);
  60.             ResPropSetInt(GuiSiblingByName("state_tax"),"Hidden",FALSE);
  61.             ResPropSetInt(GuiSiblingByName("sleep_message"),"Hidden",FALSE);
  62.           } else {
  63.             ResPropSetInt(GuiSiblingByName("plate"),"Hidden",TRUE);
  64.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"rest_x"));
  65.             ResPropSetInt(GuiSiblingByName("can_sleep_layer"),"Hidden",TRUE);
  66.             ResPropSetInt(GuiSiblingByName("cannot_sleep_layer"),"Hidden",TRUE); 
  67.             ResPropSetInt(GuiSiblingByName("state_tax"),"Hidden",TRUE);
  68.             ResPropSetInt(GuiSiblingByName("sleep_message"),"Hidden",TRUE);
  69.           }
  70.         }
  71.       }
  72.       },        
  73.     GuiAnimation("guage") {
  74.       AnimationID = "gui/dash/tab/tab_gauge/tab_gauge.anm";
  75.       Y = 122;
  76.       X = 5;
  77.       ScriptID = script {
  78.         @animate {
  79.           resid Player;
  80.           resid Game;
  81.           int frame_count;
  82.           int player_fatigue;
  83.           int frame;
  84.           
  85.           Game = ResByName("Game");
  86.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  87.           frame_count = ResPropGetInt(SELF, "FrameCount");
  88.           ResPropAlias(Player,"player_fatigue","player_fatigue");
  89.  
  90.           frame_count -= 1;
  91.           frame = (frame_count * player_fatigue) / ResPropGetInt(Game,"game_fatigue_limit");
  92.           frame = frame_count - frame;
  93.  
  94.           if (frame < 0) {
  95.             frame = 0;
  96.           }          
  97.           
  98.           ResPropSetInt(SELF,"CurrentFrame",frame);
  99.         }
  100.       };
  101.     },
  102.  
  103.         GuiTextInput("sleep_message") {
  104.       X = 45;
  105.       Y = 4;
  106.       InputDisabled = TRUE;
  107.       WordWrap = TRUE;
  108.       Width = 180;
  109.       Height = 44;
  110.       FontID = "font/verdana_9.tf";
  111.       ScriptID = Script {
  112.         @animate { 
  113.           resid Player;
  114.           resid Game;
  115.           resid fatique_data_id;
  116.           
  117.           int row_count;
  118.           str fatigue_state;
  119.           int last_slept;
  120.           int time;
  121.           int fatigue;
  122.           int message_row;
  123.  
  124.           fatique_data_id = ResPropGetResID(ResByName("CSVData"), "fatigue_id");
  125.           Game = ResByName("Game");
  126.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  127.  
  128.           /* if we can stop here, show appropriate options below */
  129.           if (ResPropGetInt(Player,"nav_can_sleep") == 1) {
  130.             ResPropSetInt(GuiSiblingByName("can_sleep_layer"),"Hidden",FALSE);
  131.             ResPropSetInt(GuiSiblingByName("cannot_sleep_layer"),"Hidden",TRUE);  
  132.           } else {
  133.             ResPropSetInt(GuiSiblingByName("can_sleep_layer"),"Hidden",TRUE);
  134.             ResPropSetInt(GuiSiblingByName("cannot_sleep_layer"),"Hidden",FALSE);  
  135.           }
  136.  
  137.           last_slept = ResPropGetInt(Player,"player_last_slept");
  138.           time       = ResPropGetInt(Player,"time_now");
  139.           last_slept = ((time - last_slept) / 60) /60; 
  140.  
  141.           fatigue = ResPropGetInt(Player,"player_fatigue");
  142.           row_count = CSVGetRowCount(fatique_data_id);
  143.  
  144.           message_row = (row_count * fatigue) /  ResPropGetInt(Game,"game_fatigue_limit");
  145.           if (message_row > row_count) {
  146.             message_row = row_count -1;
  147.           }
  148.               
  149.           fatigue_state = CSVGetStr(fatique_data_id,"phrase",message_row);
  150.           
  151.           ResPropSetStr(SELF,"InputText",
  152.             StrFormatStr(
  153.              MangleSIDToStr(219/*"You last slept %d hours ago. %s."*/),
  154.              last_slept,
  155.              fatigue_state
  156.             )
  157.           );
  158.         }
  159.       };
  160.     },
  161.     GuiAnimation("line") {
  162.       AnimationID = "gui/dash/tab/line/line.pcx";
  163.       X = 45;
  164.       Y = 35;
  165.     },
  166.     
  167.     GuiLayer("can_sleep_layer") {
  168.       X = 45;    
  169.       Y = 40;
  170.       ChildID = {
  171.  
  172.             GuiTextInput("where_to_sleep_message") {
  173.           X = 0;
  174.           Y = 0;
  175.           InputDisabled = TRUE;
  176.           WordWrap = TRUE;
  177.           Width = 180;
  178.           Height = 60;
  179.           FontID = "font/verdana_9.tf";
  180.           ScriptID = Script {
  181.             @animate { 
  182.               resid Player;
  183.               resid Game;
  184.               resid city_data_id;
  185.               int lodge_tax;
  186.               int bill;
  187.               int hotel_unit_cost;
  188.               str cur_city;
  189.               
  190.               Game = ResByName("Game");
  191.               city_data_id  = ResPropGetResID(ResByName("CSVData"), "city_id");
  192.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  193.               cur_city = ResPropGetStr(Player,"nav_cur_city");
  194.               lodge_tax = StrToInt(CSVGetStr(city_data_id,"lodging_tax",CSVSearch(city_data_id,"name",cur_city)));
  195.               hotel_unit_cost = ResPropGetInt(ResByName("Game"),"game_hotel_unit_cost");
  196.               bill += hotel_unit_cost;
  197.               bill *= lodge_tax;
  198.               bill /= 10000;
  199.               bill += hotel_unit_cost;
  200.             
  201.               ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(220/*"Sleeping in a hotel in %s will cost $%s, but you'll sleep better than you would in your truck."*/),ResPropGetStr(Player,"nav_cur_city"), IntToDecimalStr(bill,100) ));
  202.  
  203.             }
  204.           };
  205.         },
  206.  
  207.         GuiButtonGroup("sleep_in_hotel") {
  208.           X = 15;
  209.           Y = 60;
  210.           RadioGroupID = 1;
  211.           ScriptID = Script {
  212.  
  213.             @activate {
  214.               resid Player;
  215.               resid Game;
  216.               int capacity;
  217.               int remaining;
  218.               Game = ResByName("Game");
  219.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  220.               ResPropSetInt(Player,"player_where_to_sleep",1);
  221.             }
  222.           };
  223.           ChildID = {
  224.                   GuiButton("sleep_in_hotel_off") {
  225.                     HorizontalAlign = RIGHTOF;
  226.               HorizontalPadding = 6;
  227.                   StyleID = "gui/bs/radiounsel.gbs";
  228.                   TextID = Mangle(221/*"Hotel"*/);
  229.               FontID = "font/tab_w_on_g.tf";    
  230.                  },          
  231.     
  232.                 GuiButton("sleep_in_hotel_on") {
  233.                     HorizontalAlign = RIGHTOF;
  234.               HorizontalPadding = 6;            
  235.                   StyleID = "gui/bs/radiosel.gbs";
  236.                   TextID = Mangle(222/*"Hotel"*/);
  237.               FontID = "font/tab_w_on_g.tf";      
  238.                  }        
  239.           };
  240.         },
  241.         
  242.         GuiButtonGroup("sleep_in_truck") {
  243.           X = 15;
  244.           Y = 80;
  245.           RadioGroupID = 1;
  246.           ScriptID = Script {
  247.             @activate {
  248.               resid Player;
  249.               resid Game;
  250.               int capacity;
  251.               int remaining;
  252.               Game = ResByName("Game");
  253.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  254.               ResPropSetInt(Player,"player_where_to_sleep",0);
  255.             }
  256.           };
  257.           ChildID = {
  258.                   GuiButton("sleep_in_truck_off") {
  259.                     HorizontalAlign = RIGHTOF;
  260.               HorizontalPadding = 6;
  261.                   StyleID = "gui/bs/radiounsel.gbs";
  262.                   TextID = Mangle(223/*"Truck"*/);
  263.               FontID = "font/tab_w_on_g.tf";    
  264.                  },          
  265.     
  266.                 GuiButton("sleep_in_truck_on") {
  267.                     HorizontalAlign = RIGHTOF;
  268.               HorizontalPadding = 6;            
  269.                   StyleID = "gui/bs/radiosel.gbs";
  270.                   TextID = Mangle(224/*"Truck"*/);
  271.               FontID = "font/tab_w_on_g.tf";      
  272.                  }        
  273.           };
  274.         },
  275.         
  276.         GuiButton("Sleep") {
  277.           X = 80;
  278.           Y = 60;
  279.           TextID = Mangle(225/*"Sleep"*/);
  280.           StyleID = "gui/dash/tab/button/tab.gbs";
  281.           FontID = "font/tab_button.tf";
  282.           Width = 85;
  283.           AutoSize = Height;
  284.           ScriptID = Script {
  285.             @activate {
  286.               resid Player;
  287.               resid Game;
  288.               resid city_data_id;
  289.               resid Message;
  290.               resid SelectedPlaceToSleep;
  291.               int fatigue;
  292.               int time_now;
  293.               int player_last_slept;
  294.               int lodge_tax;
  295.               int bill;
  296.               int hotel_unit_cost;
  297.               str cur_city;
  298.               int expense_spent_on_hotel;
  299.               int player_where_to_sleep;
  300.               
  301.               Game = ResByName("Game");
  302.               city_data_id = ResPropGetResID(ResByName("CSVData"), "city_id");
  303.               Message = ResByName("dash.gl/message");
  304.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");         
  305.                        
  306.               ResPropAlias(Player,"player_where_to_sleep","player_where_to_sleep");
  307.               ResPropAlias(Player,"player_fatigue","fatigue");
  308.               ResPropAlias(Player,"time_now","time_now");
  309.               ResPropAlias(Player,"player_last_slept","player_last_slept");
  310.               ResPropAlias(Player,"expense_spent_on_hotel","expense_spent_on_hotel");
  311.               
  312.               
  313.               /* make sure we have a value */
  314.               SelectedPlaceToSleep = ResPropGetResID(GuiSiblingByName("sleep_in_hotel"),"RadioGroupSelectedID");
  315.               ResParseEvent(SelectedPlaceToSleep,"@activate");
  316.               
  317.               /* if we dont need sleep */
  318.               if (fatigue < 10800 /* 3 hours */) {
  319.                 ResPropSetStr(Message, "InputText", MangleSIDToStr(226/*"You are not tired enough to sleep."*/));
  320.                 ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 3);
  321.                 stop;
  322.               }
  323.               
  324.               /* if the wipers are on then shutem down */
  325.               if (ResPropGetInt(Player,"truck_wiper") == 1) {
  326.                 ResParseEvent(ResByName("dash.gl/wiper_switch"),"@activate");
  327.               }
  328.  
  329.               /* if the lights are on then shutem down */
  330.               if (ResPropGetInt(Player,"truck_light") == 1) {
  331.                 ResParseEvent(ResByName("dash.gl/light_switch"),"@activate");
  332.               }              
  333.               
  334.               /* if we are sleeping in the truck... */
  335.               if ( ResPropGetInt(Player,"player_where_to_sleep") == 0 /*truck*/ ) {
  336.                 ResPropSetStr(Player, "nav_picture", "sleep_in_truck");
  337.                 ResPropSetStr(Player, "nav_sound", "sleep_in_truck");
  338.                 ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
  339.                 ResPropSetInt(Player, "truck_seatbelt", 0); 
  340.                 ResParseEvent(ResByName("dash.gl/seatbelt"),"@show");  
  341.                 ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);              
  342.  
  343.                 fatigue -= 43200; /* take off 6 hours * 2 */
  344.                 if (fatigue < 0) {
  345.                   fatigue = 0;
  346.                 }
  347.                                 
  348.                 time_now += 21600; /* add 6 hours */
  349.                 player_last_slept = time_now; 
  350.  
  351.                 ResPropSetStr(Message,"InputText",MangleSIDToStr(227/*"You toss and turn and wake up somewhat refreshed six hours later."*/));
  352.                 ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 10);
  353.                 
  354.  
  355.               } else {
  356.               
  357.                 ResPropSetStr(Player, "nav_picture", "hotel");
  358.                 ResPropSetStr(Player, "nav_sound", "hotel");
  359.                 ResPropSetInt(Player, "truck_seatbelt", 0); 
  360.                 ResParseEvent(ResByName("dash.gl/seatbelt"),"@show");               
  361.                 if (ResPropGetInt(Player,"nav_at_city") == 0) {   
  362.                   ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
  363.                 }                
  364.                 ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);
  365.                 fatigue = 0;
  366.                 time_now += 28800; /* add 8 hours */
  367.                 player_last_slept = time_now;
  368.                 cur_city = ResPropGetStr(Player,"nav_cur_city");
  369.                 lodge_tax = StrToInt(CSVGetStr(city_data_id,"lodging_tax",CSVSearch(city_data_id,"name",cur_city)));
  370.                 hotel_unit_cost = ResPropGetInt(ResByName("Game"),"game_hotel_unit_cost");
  371.                 bill += hotel_unit_cost;
  372.                 bill *= lodge_tax;
  373.                 bill /= 10000;
  374.                 bill += hotel_unit_cost;
  375.  
  376.                 expense_spent_on_hotel += bill;  
  377.                                 
  378.                 ResPropSetStr(Message,"InputText",StrFormatStr(MangleSIDToStr(228/*"You sleep at a hotel in %s and wake up eight hours later. You pay $%s."*/),cur_city, IntToDecimalStr(bill,100) ));
  379.                 ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 10);
  380.                 
  381.               }
  382.                        
  383.             }
  384.           };
  385.         }
  386.       };
  387.     },     
  388.     
  389.     GuiLayer("cannot_sleep_layer") {
  390.       X = 45;    
  391.       Y = 60;
  392.       ChildID = {
  393.             GuiTextInput("no_sleep_message") {
  394.           X = 0;
  395.           Y = 0;
  396.           Width = 185;
  397.           Height = 50;
  398.           WordWrap = TRUE;
  399.           InputDisabled = TRUE;
  400.           FontID = "font/tab_w_on_g.tf";
  401.           ScriptID = Script {
  402.             @loaded {
  403.            
  404.               ResPropSetStr(SELF,"InputText",MangleSIDToStr(229/*"You cannot sleep here. Look for a rest stop sign or stop in the next city."*/));
  405.             }
  406.           };
  407.         }   
  408.       };
  409.     },         
  410.     GuiAnimation("line1") {
  411.       AnimationID = "gui/dash/tab/line/line.pcx";
  412.       Y = 142;
  413.       X = 45;
  414.     },
  415.         GuiTextInput("state_tax") {
  416.       X = 45;
  417.       Y = 144;
  418.       Width = 185;
  419.       Height = 35;
  420.       WordWrap = TRUE;
  421.       InputDisabled = TRUE;
  422.       FontID = "font/verdana_9.tf";
  423.       ScriptID = Script {
  424.         @animate {
  425.           resid Player;
  426.           resid Game;
  427.           resid city_data_id;
  428.           int lodge_tax;
  429.           str cur_city;
  430.  
  431.           Game = ResByName("Game");
  432.           city_data_id  = ResPropGetResID(ResByName("CSVData"), "city_id");
  433.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  434.           cur_city = ResPropGetStr(Player,"nav_cur_city");
  435.           lodge_tax = CSVGetInt(city_data_id,"lodging_tax",CSVSearch(city_data_id,"name",cur_city)) / 100;
  436.           ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(230/*"%s has a lodging tax of %d percent."*/),ResPropGetStr(Player,"nav_cur_city"), lodge_tax ));
  437.         }
  438.       };
  439.     }
  440.   };
  441. }
  442.